import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login.vue'
import Detail from '../views/Detail.vue'
import NavBar from '../components/NavBar.vue'
// import Copyright from '../components/Copyright.vue'

// 使用 Vue 的插件 VueRouter
Vue.use(VueRouter)

// 创建 VueRouter 对象
const router = new VueRouter({
  mode: 'hash', // 路由模式-hash、history
  // mode: 'history',
  routes: [ // 静态路由配置
    {
      path: '/home', // URL 路径
      component: Home // 对应渲染的路由组件，向默认名称的视图中渲染
    },
    {
      path: '/login',
      // component: Login
      components: {
        header: NavBar,
        default: Login
      }
    },
    {
      path: '/detail',
      // path: '/detail/:id',
      component: Detail,
      // components: {
      //   header: NavBar,
      //   default: Detail,
      //   footer: Copyright
      // },
      props: true
    }
  ]
})

export default router
